package com.data.basic.chapter09;

/**
 * @author wang on 2018/7/2.
 */
public class Main {
    public static void main(String[] args) {
        Integer [] num = {-2,0,3,-5,2,-1};
        SegmentTree<Integer> segmentTree = new SegmentTree<Integer>(num, new Merger<Integer>() {
            public Integer merger(Integer a, Integer b) {

                return a+b;
            }
        });
        //lambda表达式
        SegmentTree<Integer> segmentTree1 = new SegmentTree<Integer>(num, (a,b)->a+b);
        System.out.println(segmentTree);
        Integer query = segmentTree.query(0, 3);
        System.out.println(query);
        segmentTree.set(3,9);
        System.out.println(segmentTree);
    }
}
